From b42a1fafc6fcec65ca80ee2b4076e147ac0f1e57 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Fri, 1 Jul 2005 15:47:46 +0000 Subject: [PATCH] Other than native x86-64 code, the XEN guest *does* use 4k mappings for the contiguous kernel mapping of (physical) memory. Thus the code in change_page_attr needs to work like on i386 (where large pages are used only conditionally) rather than like native x86-64. Patch below/attached. Not doing so triggered the BUG_ON during load of intel-agp on machines with i915 chipset. Signed-off-by: Jan Beulich --- .../arch/xen/x86_64/mm/pageattr.c | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/pageattr.c b/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/pageattr.c index 63e9a38a17..4afb9c26e4 100644 --- a/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/pageattr.c +++ b/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/pageattr.c @@ -166,16 +166,23 @@ __change_page_attr(unsigned long address, unsigned long pfn, pgprot_t prot, BUG(); /* on x86-64 the direct mapping set at boot is not using 4k pages */ - BUG_ON(PageReserved(kpte_page)); - - switch (page_count(kpte_page)) { - case 1: - save_page(address, kpte_page); - revert_page(address, ref_prot); - break; - case 0: - BUG(); /* memleak and failed 2M page regeneration */ - } +// BUG_ON(PageReserved(kpte_page)); + /* + * ..., but the XEN guest kernels (currently) do: + * If the pte was reserved, it means it was created at boot + * time (not via split_large_page) and in turn we must not + * replace it with a large page. + */ + if (!PageReserved(kpte_page)) { + switch (page_count(kpte_page)) { + case 1: + save_page(address, kpte_page); + revert_page(address, ref_prot); + break; + case 0: + BUG(); /* memleak and failed 2M page regeneration */ + } + } return 0; } -- 2.30.2